package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Host     string
		Password string
		Db       int
	}
	AliYun struct {
		AccessKeyID     string
		AccessKeySecret string
	}
	QiNiuYun struct {
		AccessKeyID     string
		AccessKeySecret string
		Bucket          string
		Url             string
	}
	Jwt struct {
		APP_KEY string
	}
}

var AppConf Config

func ViperInit() {
	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
		return
	}
	err = viper.Unmarshal(&AppConf)
	fmt.Println(AppConf)
	if err != nil {
		fmt.Println("配置文件解析失败")
		return
	}
	fmt.Println("配置文件解析成功")
}
